<%@ page import="entity.Field" %>
<%@ page import="java.util.List" %>
<%@ page import="entity.Passage" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    String course =(String) request.getAttribute("courseName");
    String bottom_content  = (String) request.getAttribute("bottom_content");
    Field field = (Field) request.getAttribute("field");
    List<Passage> passages = null;
    passages = (List<Passage>) request.getAttribute("passages");
    int current_page = (int) request.getAttribute("page");
    int num_every_page = 10;
    int last_page = (int) request.getAttribute("last_page");

%>
<html>
<head>
    <title>问题与答疑</title>
    <link type="text/css" rel="stylesheet" href="css/common.css"/>
    <link type="text/css" rel="stylesheet" href="css/field.css" />
    <script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<div id="top">
    <img  src="image/top.png" style="width: 1349px; height: 249px; position: absolute">
    <h1 style="font-size: 30px; color:white; position:absolute;padding-left: 250px; padding-top: 100px; margin: 0"><%=course%>精品课程</h1>

    <form action="SearchAllServlet" method="post" style="position: absolute; padding-left: 764px;padding-top: 174px; margin:0">
        <span style="color: orange">全站搜索</span>
        <input type="text" name="searchAll" id="searchAll" style="width:200px" placeholder="请输入搜索内容" />
        <input onclick="return check() " type="submit" style="background-color: #e8b108; border-color: yellow;border-left: 0;border-right: 0" value="搜索" />
    </form>

    <ul id="nav">
        <li class="sub_nav"><a href="IndexServlet" style="text-decoration: none;color:white">首页</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=11" style="text-decoration: none;color:white">课程介绍</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=21" style="text-decoration: none;color:white">教学团队</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=31" style="text-decoration: none;color:white">课程建设</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=41" style="text-decoration: none;color:white">课程资源</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=61" style="text-decoration: none;color:white">问题与答疑</a></li>
        <li class="sub_nav"><a href="FieldServlet?field=51" style="text-decoration: none;color:white">课程研究</a></li>
        <li class="sub_nav"><a href="MessageServlet?page=1" style="text-decoration: none;color:white">留言板</a></li>
    </ul>

</div>

<div id="content">
    <form action="SearchServlet" method="post" id="search_box">
        <input type="text" name="search" placeholder="请输入搜索标题" id="search_passage"/>
        <input type="text" name="field" style="display: none" value="<%=field.getFieldID()%>"/>
        <input type="submit" onclick="return check2()" style="width: 35px;height: 20px;border: 1px solid red; background-color: #e53c3e;color:white;padding:0" value="搜索" />
    </form>

    <div style="width: 960px;height: 776px;padding-top: 60px;">
        <div style="border-bottom: 2px solid red;padding-bottom: 2px">
            <img src="image/icon.png" />
            <span style="color: red"><%=field.getFieldName()%></span>
            <span style="float: right">
                    <span style="color:orangered">您的当前位置：</span>
                    <a href="FieldServlet?field=11" class="link">问题与答疑</a>
                </span>
        </div>
        <p style="font-size: 15px;line-height: 22px;margin-top:10px;">
            <%for( int i = 0; i < num_every_page && i < passages.size(); i++){%>
            <p style="margin: 0;font-size:14px;padding-left:10px;line-height: 30px">
                <%if (passages.get(i).isRoof()){%>
                <span><img src="image/roof.png" /></span>
                <%}%>
                <a href="PassageServlet?passageId=<%=passages.get(i).getPassageId()%>&field=<%=field.getFieldID()%>" class="link">
                    <%=passages.get(i).getTitle()%>
                </a>
                <span style="float: right"><%=passages.get(i).getCreateDate()%></span>
            </p>
            <%}%>

            <form action="PassageServlet" method="post" style="margin-top: 90px;text-align: center">
                <input type="submit" onclick="to_first_page()" id="page_first_btn" value="首页"/>
                <input type="submit" onclick="page_up()" id="page_up_btn" value="上一页"/>
                <input type="button" style="color:black;border-color: darkblue" value="<%=current_page%>"/>
                <input type="submit" onclick="page_down()" id="page_down_btn"  value="下一页"/>
                <input type="submit" onclick="to_last_page()" id="page_last_btn" value="尾页"/>
                <input type="text" style="display: none;" id="current_page" value="<%=current_page%>" />
                <input type="text" style="display: none;" id="last_page" value="<%=last_page%>" />
                <input type="text" style="display: none;" name="next_page" id="next_page" />
                <input type="text" style="display: none;" name="field" value="<%=field.getFieldID()%>" />
                <script>page_initial();</script>
            </form>
        </p>
    </div>
</div>

<div id="bottom">
    <div id="bottom1"></div>
    <div style="height: 2px"></div>
    <div id="bottom2">
        <div>
            <p style="text-align: center; margin: 0; padding: 32px 0 12px 0"><%=bottom_content%></p>
        </div>
    </div>
</div>
</body>
</html>